package Code.StringTraverse;

//查看身份证
public class Test6 {
    public static void main(String[] args) {

        String identity = "421122200104226316";

        //获取出生年月日
        String year = identity.substring(6, 10);
        String month = identity.substring(10, 12);
        String day = identity.substring(12, 14);

        System.out.println("出生年月日为："+year+"年"+month+"月"+day+"日");

        //获取性别
        char gender = identity.charAt(16);

        //利用ascll来让字符转换成数字
        int num = gender - 48;

        if (num % 2 == 0) {
            System.out.println("性别为：女");
        } else {
            System.out.println("性别为：男");
        }
    }
}
